package de.szut.traineeslife.db;

import java.util.List;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.widget.TextView;
import de.szut.traineeslife.R;
import de.szut.traineeslife.data.User;

public class DataAdapter extends SimpleCursorAdapter {

	public DataAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
		super(context, layout, c, from, to, flags);
		// TODO Auto-generated constructor stub
	}

	Context mContext;
	private List<User> userList;

	@Override
	public void bindView(View v, final Context context, final Cursor cursor) {
		ViewHolder vh = (ViewHolder) v.getTag();
		if (vh == null) {
			vh = new ViewHolder();
			vh.titel = (TextView) v.findViewById(R.id.report_item_titel);
			vh.date = (TextView) v.findViewById(R.id.report_item_dates);
		}
		vh.titel.setText(cursor.getString(cursor.getColumnIndex(de.szut.traineeslife.db.ReportContract.Report.KEY_TITEL)));
		vh.date.setText(cursor.getString(cursor.getColumnIndex(de.szut.traineeslife.db.ReportContract.Report.KEY_STARTDATE))
				+ cursor.getColumnIndex(de.szut.traineeslife.db.ReportContract.Report.KEY_ENDDATE));

		v.setTag(vh);
	}

	class ViewHolder {
		TextView titel, date;
	}
}
